%--------------------------------------------------------------------------
%
% computes the coefficients w_hat(z) [the velocity in the linearized
% problem. 
%
% note that w_hat is assumed to be of the form
%
%   w_hat = [A(1) * z + A(2)] * cosh(k*z) + [A(3) * z + A(4)] * sinh(k*z) 
%
%--------------------------------------------------------------------------

function A = w_coeffs(c, h, k, p)

if nargin == 3
    p = params;
end

ch = cosh(k*h);
sh = sinh(k*h);
denom = ch .* sh - k.*h;

A = zeros(length(h), 4);

A(:,1) = -p.Ma / 2 * c * k^2 * h .* sh ./ denom - ...
    p.delta * c * k * (k * h .* sh + ch) ./ denom;

A(:,2) = 0;

A(:,3) = p.Ma * c / 2 * k * (k*h.*ch - sh) ./ denom ...
    + p.delta * c * (h.*k^2.*ch) ./ denom;

A(:,4) = -A(1) / k;